<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
<meta name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">

    <meta name="author" content="kissdata">


    <meta name="subtitle" content="人生笔记">


    <meta name="description" content="南邮计算机学院2021毕业生王鹏的介绍，cs软件工程专业">


    <meta name="keywords" content="wangpeng 王鹏 南邮 南京">


<title>🆗 搭建工作用的 Ubuntu | 王鹏的小岛</title>



    <link rel="icon" href="/myIcon.ico">




    <!-- stylesheets list from _config.yml -->
    
    <link rel="stylesheet" href="/css/style.css">
    



    <!-- scripts list from _config.yml -->
    
    <script src="/js/script.js"></script>
    
    <script src="/js/tocbot.min.js"></script>
    



    
    
        <!-- MathJax配置，可通过单美元符号书写行内公式等 -->
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
    "HTML-CSS": {
        preferredFont: "TeX",
        availableFonts: ["STIX","TeX"],
        linebreaks: { automatic:true },
        EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50)
    },
    tex2jax: {
        inlineMath: [ ["$", "$"], ["\\(","\\)"] ],
        processEscapes: true,
        ignoreClass: "tex2jax_ignore|dno",
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    },
    TeX: {
        equationNumbers: { autoNumber: "AMS" },
        noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } },
        Macros: { href: "{}" }
    },
    messageStyle: "none"
    });
</script>
<!-- 给MathJax元素添加has-jax class -->
<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>
<!-- 通过连接CDN加载MathJax的js代码 -->
<script type="text/javascript" async
        src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML">
</script>


    


<meta name="generator" content="Hexo 7.0.0"></head>

<body>
    <script>
        // this function is used to check current theme before page loaded.
        (() => {
            const currentTheme = window.localStorage && window.localStorage.getItem('theme') || '';
            const isDark = currentTheme === 'dark';
            const pagebody = document.getElementsByTagName('body')[0]
            if (isDark) {
                pagebody.classList.add('dark-theme');
                // mobile
                document.getElementById("mobile-toggle-theme").innerText = "· Dark"
            } else {
                pagebody.classList.remove('dark-theme');
                // mobile
                document.getElementById("mobile-toggle-theme").innerText = "· Light"
            }
        })();
    </script>

    <div class="wrapper">
        <header>
    <nav class="navbar">
        <div class="container">
            <div class="navbar-header header-logo"><a href="/">侠之大者</a></div>
            <div class="menu navbar-right">
                
                    <a class="menu-item" href="/update/mystate">Career</a>
                
                    <a class="menu-item" href="/category">Legend</a>
                
                    <a class="menu-item" href="/about">Me</a>
                
                <input id="switch_default" type="checkbox" class="switch_default">
                <label for="switch_default" class="toggleBtn"></label>
            </div>
        </div>
    </nav>

    
    <nav class="navbar-mobile" id="nav-mobile">
        <div class="container">
            <div class="navbar-header">
                <div>
                    <a href="/">侠之大者</a><a id="mobile-toggle-theme">·&nbsp;Light</a>
                </div>
                <div class="menu-toggle" onclick="mobileBtn()">&#9776; Menu</div>
            </div>
            <div class="menu" id="mobile-menu">
                
                    <a class="menu-item" href="/update/mystate">Career</a>
                
                    <a class="menu-item" href="/category">Legend</a>
                
                    <a class="menu-item" href="/about">Me</a>
                
            </div>
        </div>
    </nav>

</header>
<script>
    var mobileBtn = function f() {
        var toggleMenu = document.getElementsByClassName("menu-toggle")[0];
        var mobileMenu = document.getElementById("mobile-menu");
        if(toggleMenu.classList.contains("active")){
           toggleMenu.classList.remove("active")
            mobileMenu.classList.remove("active")
        }else{
            toggleMenu.classList.add("active")
            mobileMenu.classList.add("active")
        }
    }
</script>
            <div class="main">
                <div class="container">
    
    
        <div class="post-toc">
    <div class="tocbot-list">
    </div>
    <div class="tocbot-list-menu">
        <a class="tocbot-toc-expand" onclick="expand_toc()">Expand all</a>
        <a onclick="go_top()">Back to top</a>
        <a onclick="go_bottom()">Go to bottom</a>
    </div>
</div>

<script>
    var tocbot_timer;
    var DEPTH_MAX = 6; // 为 6 时展开所有
    var tocbot_default_config = {
        tocSelector: '.tocbot-list',
        contentSelector: '.post-content',
        headingSelector: 'h1, h2, h3, h4, h5',
        orderedList: false,
        scrollSmooth: true,
        onClick: extend_click,
    };

    function extend_click() {
        clearTimeout(tocbot_timer);
        tocbot_timer = setTimeout(function() {
            tocbot.refresh(obj_merge(tocbot_default_config, {
                hasInnerContainers: true
            }));
        }, 420); // 这个值是由 tocbot 源码里定义的 scrollSmoothDuration 得来的
    }

    document.ready(function() {
        tocbot.init(obj_merge(tocbot_default_config, {
            collapseDepth: 1
        }));
    });

    function expand_toc() {
        var b = document.querySelector('.tocbot-toc-expand');
        var expanded = b.getAttribute('data-expanded');
        expanded ? b.removeAttribute('data-expanded') : b.setAttribute('data-expanded', true);
        tocbot.refresh(obj_merge(tocbot_default_config, {
            collapseDepth: expanded ? 1 : DEPTH_MAX
        }));
        b.innerText = expanded ? 'Expand all' : 'Collapse all';
    }

    function go_top() {
        window.scrollTo(0, 0);
    }

    function go_bottom() {
        window.scrollTo(0, document.body.scrollHeight);
    }

    function obj_merge(target, source) {
        for (var item in source) {
            if (source.hasOwnProperty(item)) {
                target[item] = source[item];
            }
        }
        return target;
    }
</script>
    

    
    <article class="post-wrap">
        <header class="post-header">
            <h1 class="post-title">🆗 搭建工作用的 Ubuntu</h1>
            
                <div class="post-meta">
                    
                        Author: <a itemprop="author" rel="author" href="/">kissdata</a>
                    

                    
                        <span class="post-time">
                        Date: <a href="#">Dec 8, 2023&nbsp;&nbsp;20:30</a>
                        </span>
                    
                    
                        <span class="post-category">
                    Category:
                            
                                <a href="/categories/Work-Experience/">Work Experience</a>
                            
                        </span>
                    
                </div>
            
        </header>

        <div class="post-content">
            <p>环境 <kbd>VMware17</kbd> + <kbd>Ubuntu22.04</kbd> 虚拟机设备配置</p>
<ol>
<li>内存：4G</li>
<li>处理器：2个</li>
<li>总大小：99G</li>
</ol>
<h2 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h2><p><code>lrzsz</code> 提供 <code>rz</code> 命令来上传文件，<code>policycoreutils</code> 提供 <code>sestatus</code> 命令查看selinux状态。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">apt install -y lrzsz vim \</span><br><span class="line">    tree curl \</span><br><span class="line">    policycoreutils </span><br></pre></td></tr></table></figure>

<p>第一次可能不能联网，先 <code>cat /etc/resolv.conf</code> 看看，如果末尾行缺少 114 标志，执行。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">sudo <span class="built_in">chmod</span> 666 /etc/resolv.conf</span><br><span class="line"><span class="built_in">echo</span> <span class="string">&quot;nameserver 114.114.114.114&quot;</span> &gt;&gt; /etc/resolv.conf</span><br><span class="line">sudo /etc/init.d/networking restart</span><br></pre></td></tr></table></figure>

<h3 id="1-1-增加root控制"><a href="#1-1-增加root控制" class="headerlink" title="1.1 增加root控制"></a>1.1 增加root控制</h3><p>选用 最小安装，安装完成后需要先 <code>sudo passwd root</code> 提供 root 密码，然后设置远程能够以 root 身份登录。先换源</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/apt/sources.list</span><br><span class="line">66dd</span><br><span class="line">i</span><br></pre></td></tr></table></figure>

<p>参考 <a target="_blank" rel="noopener" href="https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/">ubuntu | Tsinghua Open Source Mirror</a> 将内容复制进去。再 <code>apt update</code> </p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install openssh-server -y</span><br><span class="line">sudo vim /etc/ssh/sshd_config</span><br></pre></td></tr></table></figure>

<p>将 <code>#PermitRootLogin</code> 的值改成 yes。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo service ssh restart</span><br><span class="line">ps -ef | grep [s]shd     # 确认服务启动成功</span><br></pre></td></tr></table></figure>

<p>固定ip（略）</p>
<img src="setip.png" alt="" style="zoom:90%;" />

<p>重启。 xshell连上</p>
<h3 id="1-2-Git设置"><a href="#1-2-Git设置" class="headerlink" title="1.2 Git设置"></a>1.2 Git设置</h3><p>安装最新版git，参考另外文章</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name <span class="string">&quot;wang7peng&quot;</span></span><br><span class="line">git config --global user.email <span class="string">&quot;18795975517@163.com&quot;</span></span><br><span class="line">git config --global http.sslVerify <span class="string">&quot;false&quot;</span></span><br></pre></td></tr></table></figure>



<h2 id="开发需要"><a href="#开发需要" class="headerlink" title="开发需要"></a>开发需要</h2><h3 id="2-1-更换bash"><a href="#2-1-更换bash" class="headerlink" title="2.1 更换bash"></a>2.1 更换bash</h3><p>使用 zsh</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> --depth 1 https://github.com/wang7peng/bashConf.git</span><br><span class="line"><span class="built_in">cd</span> bashConf</span><br><span class="line">bash install.sh</span><br></pre></td></tr></table></figure>

<p>可能wget得到的sh脚本无效，需要新建一个文档，然后直接将内容 <a target="_blank" rel="noopener" href="https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh">ohmyzsh&#x2F;tools&#x2F;install.sh</a> 复制。（不需要 <code>chmod</code> ）</p>
<p>安装完成后</p>
<img src="setbash.png" alt="终端示例" />

<p>vim设置</p>
<h3 id="2-2-指定版本的-cmake-gcc"><a href="#2-2-指定版本的-cmake-gcc" class="headerlink" title="2.2 指定版本的 cmake gcc"></a>2.2 指定版本的 cmake gcc</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">apt install gcc-12 g++-12</span><br><span class="line">gcc-12 -v</span><br><span class="line"><span class="built_in">ln</span> -s /usr/bin/gcc-12 /usr/bin/gcc</span><br><span class="line"><span class="built_in">ln</span> -s /usr/bin/g++-12 /usr/bin/g++</span><br><span class="line">gcc -v</span><br></pre></td></tr></table></figure>

<p>cmake 默认的是3.22，最新的用 snap 装</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">snap install cmake --classic</span><br></pre></td></tr></table></figure>

<p>同理 go语言开发环境安装</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz</span><br><span class="line">tar -C /usr/local -xzf go1.2* </span><br><span class="line"><span class="built_in">ln</span> -s /usr/local/go/bin/* /usr/local/bin/</span><br></pre></td></tr></table></figure>

<p>其余同 CentOS7 安装 go 环境</p>
<h2 id="2-3-IDE安装"><a href="#2-3-IDE安装" class="headerlink" title="2.3 IDE安装"></a>2.3 IDE安装</h2><p>等打了快照后再继续，安装 typora，vscode。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">wget -qO - https://typoraio.cn/linux/public-key.asc | sudo <span class="built_in">tee</span> /etc/apt/trusted.gpg.d/typora.asc</span><br><span class="line"><span class="comment"># add Typora&#x27;s repository</span></span><br><span class="line">sudo add-apt-repository <span class="string">&#x27;deb https://typoraio.cn/linux ./&#x27;</span></span><br><span class="line">sudo apt-get update</span><br><span class="line"><span class="comment"># install typora</span></span><br><span class="line">sudo apt-get install typora</span><br></pre></td></tr></table></figure>

<p>或者下载 deb包，然后<code>dpkg -i xxx.deb</code></p>
<h3 id="附：项目准备"><a href="#附：项目准备" class="headerlink" title="附：项目准备"></a>附：项目准备</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo apt install libboost-dev libboost-test-dev -y <span class="comment"># boost库</span></span><br></pre></td></tr></table></figure>


        </div>

        
            <section class="post-copyright">
                
                
                
                
                     <p class="copyright-item">
                         <span>Slogan:</span>
                         <span>人生三大错觉：我躲得过去，我能反杀，是不是<strong>喜欢我?</strong></span>
                     </p>
                

            </section>
        
        <section class="post-tags">
            <div>
            </div>
            <div>
                <a href="javascript:window.history.back();">back</a>
                <span>· </span>
                <a href="/">home</a>
            </div>
        </section>
        <section class="post-nav">
            
                <a class="prev" rel="prev" href="/2023/12-14/deploy_mt7621/">💥 | Ubuntu 编译openwrt</a>
            
            
            <a class="next" rel="next" href="/2023/11-22/review_xw/">第二次工作总结 | Go</a>
            
        </section>


    </article>
</div>

            </div>
            <footer id="footer" class="footer">
    <div class="copyright">
        <span>187-9597-5517 &nbsp; 王鹏 @ <a href="https://cs.njupt.edu.cn/" target="_blank">njupt</a</span>
    </div>
</footer>

    </div>
</body>

</html>